package com.kaiwukj.android.ufamily;

import android.content.Context;

import androidx.annotation.NonNull;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.platform.app.InstrumentationRegistry;

import com.blankj.utilcode.util.LogUtils;
import com.kaiwukj.android.mcas.di.component.AppComponent;
import com.kaiwukj.android.ufamily.app.MyApplication;
import com.kaiwukj.android.ufamily.mvp.http.callback.ApiCallBack;
import com.kaiwukj.android.ufamily.mvp.model.MineModel;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.HashMap;
import java.util.Map;

@RunWith(AndroidJUnit4.class)
public class MineTest {

    // @Inject
    MineModel mModel;
    //RxErrorHandler mErrorHandler;

    @Before
    public void init() {

        Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();


        AppComponent appComponent = MyApplication.getInstance().getAppComponent();
        mModel = new MineModel(appComponent.repositoryManager());

        /*mErrorHandler = RxErrorHandler.builder()
                .with(appContext)
                .responseErrorListener(new ResponseErrorListenerImpl())
                .build();*/
    }

    @Test
    public void testAddMember() {
        Map<String, Object> params = new HashMap<>();
        params.put("roomId", "52");
        params.put("name", "楚云飞");
        params.put("type", 2);
        params.put("phone", "17606092263");
        params.put("idCardNo", "36012119950516145X");
        params.put("sex", 1);
        mModel.addHouseMember(params)
                .subscribe(new ApiCallBack<Integer>() {
                    @Override
                    public void onSuccess(@NonNull Integer result) {
                        LogUtils.d("result-------------------->" + result);
                    }
                });
    }

}
